home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
aspgue1a
/
administ.asp
next >
Wrap
Text File
|
1999-09-22
|
6KB
|
175 lines
<html>
<head>
<title>Guestbook Administration</title>
<!-- scripting , html copyright 1998 Kathi O'Shea ------->
<!-- email info@web-savant for custom web development --->
<!-- see readme.txt in zip file for modification and ---->
<!-- redistribution info -------------------------------->
</head>
<body bgcolor="#ffffff">
<center>
<font face="times new roman">
<h1><i>Guestbook Administration</i></h1>
</font>
<br>
<%
Flag = request.form("Flag")
Select Case Flag
Case 0
Flag = Flag + 1
%>
<table width=300 border=0 cellpadding=10>
<tr>
<td width=100>
<form method="post" action="administration.asp">
<font face="arial" size=2>
<b>UserID</b>
</td>
<td width=200><input type="text" name="userid"></td>
</tr>
<tr>
<td width=100><font face="arial" size=2>
<b>Password:</b>
</td>
<td width=200><input type="text" name="password"></td>
</tr>
<tr>
<td width=100> </td>
<td width=200 align="center">
<input type='hidden' name="flag" value="<%= Flag %>">
<input type="submit" value="Submit"> <input type="reset">
</td>
</tr>
</table>
<%
Case 1
UserID = request.form("userid")
Password = request.form("password")
' **** be sure to change "admin" and "password"
' **** to your choice of userid and password
If UserID <> "admin" OR Password <> "password" then
response.write "<font face='arial' color='red'>"
response.write "Invalid login. Please try again.</font>"
Else
set conn = server.createobject("adodb.connection")
' BEGIN DSN-less connection - comment out or delete if using a DSN
DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)}; "
DSNtemp=dsntemp & "DBQ=" & server.mappath("guestbook.mdb")
conn.Open DSNtemp
' END DSN-less connection - uncomment the next line if using DSN!
' conn.open "guestbook"
sqlstmt = "SELECT * from Guestbook Order by PostDate Desc"
Set RS = conn.execute(sqlstmt)
If rs.eof then
response.write "<center>There are no records in the database"
response.write "<br>Please check back later</center>"
response.end
End If
response.write "<table width=500 border=0>"
response.write "<tr><td colspan=4 align='center'>"
response.write "<font face='arial' size=3><b>"
response.write "Delete Records</b><br></font></td></tr>"
response.write "<form action='administration.asp' method='post'>"
Do while not rs.eof
' The database has an autonumber field set as
' the primary key, so we will use that field
' to specify which record we want to modify
ID = rs("ID")
Name = rs("Name")
City = rs("City")
Country = rs("Country")
%>
<tr>
<td width=15>
<input type="checkbox" name="ID" value="<%= ID %>">
</td>
<td width=185>
<font face="arial">
<%= Name %></a>
</font>
</td>
<td width=200><font face="arial"><%= City %></font></td>
<td width=100><font face="arial"><%= Country %></font></td>
</tr>
<%
rs.MoveNext
loop
%>
<tr>
<td colspan=4 align="center">
<br><br>
<input type='hidden' name="UserID" value="<%= UserID %>">
<input type='hidden' name="Password" value="<%= Password %>">
<input type='hidden' name='Flag' value='2'>
<input type="submit" value="Delete Record">
</form>
</td>
</tr>
<%
End If
Case 2
If IsEmpty(request.form("ID")) then
response.write "<font face='arial' size=3 color='red'>"
response.write "Oops! You have to check a "
response.write "box for this to work!"
response.write "<br>Please hit your Back"
response.write " button and try again."
response.end
End If
set rs = nothing
ID = request.form("ID")
UserID = request.form("UserID")
Password = request.form("Password")
set conn = server.createobject("adodb.connection")
' AS ABOVE, change path to guestbook if needed or delete
' the dsn-less connection and use a DSN
DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)}; "
DSNtemp=dsntemp & "DBQ=" & server.mappath("/guestbook.mdb")
conn.Open DSNtemp
For each record in request("ID")
sqlstmt = "DELETE * from Guestbook WHERE ID=" & record
Set RS = conn.execute(sqlstmt)
Next
If err.number>0 then
response.write "VBScript Errors Occured:" & "<P>"
response.write "Error Number=" & err.number & "<P>"
response.write "Error Descr.=" & err.description & "<P>"
response.write "Help Context=" & err.helpcontext & "<P>"
response.write "Help Path=" & err.helppath & "<P>"
response.write "Native Error=" & err.nativeerror & "<P>"
response.write "Source=" & err.source & "<P>"
response.write "SQLState=" & err.sqlstate & "<P>"
end if
IF conn.errors.count> 0 then
response.write "Database Errors Occured" & "<P>"
response.write SQLstmt & "<P>"
for counter= 0 to conn.errors.count
response.write "Error #" & conn.errors(counter).number & "<P>"
response.write "Error desc. -> " & conn.errors(counter).description & "<P>"
next
else
response.write "<font face='arial' size=4><b>"
response.write "The record has been deleted.</b></font>"
response.write "<form action='administration.asp' method='post'>"
response.write "<input type='hidden' name='flag' value='1'>"
response.write "<input type='hidden' name='UserID' value='" & UserID& "'>"
response.write "<input type='hidden' name='Password' value='" & Password & "'>"
response.write "<input type='submit' value='Back to Administration List'>"
response.write "</form>"
end if
End Select
set rs = nothing
set conn = nothing
%>
</table>
</center>
</body>
</html>